package com.luo.controller;

import com.alibaba.fastjson.JSON;
import com.luo.model.Goods;
import com.luo.service.ClassService;
import com.luo.service.GoodService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 功能：
 * 作者：Luo。
 * 日期：2024/1/11 14:30
 */
@WebServlet("/queryAllGoods")
public class GoodAllListController extends HttpServlet {

    GoodService goodService = new GoodService();

    @Override
    protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
        List<Goods> goods = goodService.queryAllGoods();
        String jsonString = JSON.toJSONString(goods);
        resp.setContentType("text/json;charset=utf-8");
        resp.getWriter().write(jsonString);
        resp.getWriter().close();
    }
}
